Tuesday, May 17, 2005

Example for Mod RewriteRule

#--MOD Rewirite--
RewriteEngine On
RewriteRule ^dir/(.*) /home/httpd/vhosts/jyvepresence.com/httpdocs/index.php?status=$1

#-----------------------
# URL will be
# http://www.domain.com/dir/vikrant
# It will execute index.php
# $1 == vikrant
#------------------------

RewriteRule ^/?([^/]*\.png|[^\./]*)[:;,\.]*$ /home/httpd/vhosts/jyvepresence.com/httpdocs/index.php?status=$1 [L,NS]

#-----------------------
# URL will be
# http://www.domain.com/vikrant.png OR http://www.domain.com/vikrant
# It will execute index.php
# $1 == vikrant.png OR $1 == vikrant
#------------------------

2 -------------------------------------
Old dynamic url:
Code:
www.domain.com/catalog.php?cat=widgets&product_id=1234
New static url:
Code:
www.domain.com/catalog/widgets-1234.html
Code:
#start .htaccess code
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^cat\=([^&]+)\&product_id\=([^&]+)$
RewriteRule ^$ /catalog/%1-%2.html [R=301,L]


Reg Expression notes:
[^&]+ mean find any character except the "&" since it is what seperates the variables in a string. you can back reference matches in a rewrite condition using ()'s just like your rewrite rules but to call them you have to use a % instead of a $.

Benefits:
1. You don't have to hand write 1,000's of 301 redirects

2. Spiders can easily pick up the 301 and pass the scores and index the new urls much faster than having to crawl the entire site over from scratch.

3. Users clicking old dynamic urls in the SERPS will not get a 404 error. They'll go straight to the new static urls.

3 -----------------------------

Browser Dependent Content


Description:

At least for important top-level pages it is sometimes necessary to provide the optimum of browser dependent content, i.e. one has to provide a maximum version for the latest Netscape variants, a minimum version for the Lynx browsers and a average feature version for all others.
Solution:

We cannot use content negotiation because the browsers do not provide their type in that form. Instead we have to act on the HTTP header "User-Agent". The following condig does the following: If the HTTP header "User-Agent" begins with "Mozilla/3", the page foo.html is rewritten to foo.NS.html and and the rewriting stops. If the browser is "Lynx" or "Mozilla" of version 1 or 2 the URL becomes foo.20.html. All other browsers receive page foo.32.html. This is done by the following ruleset:

RewriteCond %{HTTP_USER_AGENT} ^Mozilla/3.*
RewriteRule ^foo\.html$ foo.NS.html [L]

RewriteCond %{HTTP_USER_AGENT} ^Lynx/.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[12].*
RewriteRule ^foo\.html$ foo.20.html [L]

RewriteRule ^foo\.html$ foo.32.html [L]

4-----------------------------------------------------

Simple Example

Just to help illustrate how you could use this information let's assume we had 3 web pages:

http://www.desilva.biz/wd_010427.php
http://www.desilva.biz/grafix_index.php
http://www.desilva.biz/hw_010506.php

and we want to re-direct our readers visiting each page above to their new versions at:

http://www.desilva.biz/refresh.html
http://www.desilva.biz/grafix.html
http://www.desilva.biz/cpuspeed.html

.htaccess

RewriteEngine on
RewriteRule ^wd_010427\.php$ refresh.html [R=301,L]
RewriteRule ^grafix_index\.php$ grafix.html [R=301,L]
RewriteRule ^hw_010506\.php$ cpuspeed.html [R=301,L]



Wednesday, March 30, 2005

Fantastic JavaScripts

Java Script Regular Expressions ..... (find the match and replace it)

Replace ASP tags with blank <% anything %>

<script language=JavaScript>

var theString

theString = "<html> vikrant </html> <% cieling 'done 'dfsfd
%> <div>rahesh </div> <% goahed %> <b>vik </b>";

theString = theString.replace(/<%.*?%>/gi,' ');

alert (theString);


</script>



HELP URL : http://www.sitepoint.com/print/expressions-javascript

Monday, March 28, 2005

Jyve-Skype in NY Times

Hi friends I am very happy today for the work Iam doing from last 10 months is noticable to the and getting Popular among the web-world and the Tehnology.

This a news Article in NY times about the Jyve.com

Even without government intervention, however, random Skyping appears likely to continue in some form. The next phase may be more formalized Skype-enabled social networks like www.jyve.com, which connects people with similar interests and desire to practice a certain language, and www.someonenew.com, which connects people for romantic purposes. Only a few English-language social networking sites currently use Skype, but such sites in Asia have been very successful.

Jyve, according to Charles Carleton, a co-founder, will be introducing a feature in the next few months that Mr. Carleton hopes will protect the medium's social capabilities: an eBay-like feedback system to help users reject callers with a track record of inappropriate conversation. Skype is happy to leave these functions to other companies. "We're probably never going to run a dating service or language seminars," Ms. Larabee said of Skype. "Our business is the technology, not the networks."

Vikrant.

Friday, February 18, 2005

MySQL Functions (Usefull in Programming)

I am running on MySql 3.23.58 version

1 . Concat the String
SELECT CONCAT('My', 'S', 'QL');
-> MySQL
-----------

2. Concat with Word Separator
SELECT (CONCAT_WS(",","First name","Second name","Last Name")) as fullname;
-> First name,Second name,Last Name
-----------

3. String Length
SELECT LENGTH('text');
->4
-----------

3. String Padding (Add characters to string)
String must contin 4 character long if 1st_expr is not contain 4
charater then add 3rd_expr to String.
SELECT LPAD('hi',4,'..');
-> '..hi'
SELECT RPAD('hi',4,'..');
-> 'hi'
-----------

4. String Padding (Add character to string)
SELECT LEFT('foobarbar', 5);
->'fooba'
SELECT RIGHT('foobarbar', 5);
->'arbar'

COMBINATION OF 3 & 4 Point
SELECT RPAD(LEFT('foobarbar', 5),8,'.') as str;
-> fooba...


## Miscellaneous Functions

SELECT DATABASE();
-> current Working databse

SELECT USER();
-> curent User

SELECT SUBSTRING_INDEX(USER(),"@",1);
-> Concat userstring

SELECT VERSION();
->Current Mysql version

SELECT CONNECTION_ID();
-> Current connectio Id


MySql IFNULL, IF, CASE-WHEN-THEN -ELSE-END

IFNULL(expr,expr1)
--------------------------------------------
If 1st_ expr is null then retrun 2nd_expr

SELECT IFNULL(1,0);
-> 1
SELECT IFNULL(NULL,10);
-> 10
SELECT IFNULL(1/0,10);
-> 10
SELECT IFNULL(1/0,'yes');
-> 'yes'
--------------------------------------------------------------
CASE WHEN condiion THEN expr1 ELSE expr3 END
--------------------------------------------------------------

SELECT (CASE 2 WHEN 1 THEN "one" WHEN 2 THEN "two" ELSE "more" END) as ans;
-> two

SELECT CASE WHEN 1<0 style="color: rgb(255, 0, 0);">THEN "true" ELSE "false" END;
->false
--------------------------------------------------------------
IF(condition,expr,expr1)
--------------------------------------------------------------

SELECT IF(0.1<>0,1,0);
-> 1
SELECT IF(STRCMP('test','test1'),'no','yes');
-> no

Tuesday, February 15, 2005

How to create SubDomains by editing httpd.conf

VirtualHost:
If you want to maintain multiple domains/hostnames on your
machine you can setup VirtualHost containers for them.

Types of Virtual Hosting
1) IP-Based Virtual Hosting
2) Name-Based Virtual Hosting
3) Dynamic Virtual Hosting

Good Example how to set subDomains under NameBased Virtual Hosting :

NOTE: NameVirtualHost cannot be used without a port specifier
(e.g. :80) if mod_ssl is being used, due to the nature of the
SSL protocol.

Change Apache's httpd.conf file

NameVirtualHost 215.51.182.53

<VirtualHost 216.55.183.51>
ServerName *.yourdomain.com
ServerAlias yourdomain.com
DocumentRoot /home/rootdir #Directory where Scritpting files are located.
ErrorLog logs/error_log #Error are recorded in error_log file located /var/logs/httpd
CustomLog logs/visit_log combined # URL visit information recorded in visit_log file located /var/logs/httpd
</VirtualHost>

<VirtualHost 216.55.183.51>
ServerName subdomain.youydomain.com
ServerAlias subdomain.youydomain.com
DocumentRoot /home/rootdir/subdomain
ErrorLog logs/error_log
CustomLog logs/visit_log
</VirtualHost>

<VirtualHost 216.55.183.51>
ServerName subdomain1.youydomain.com
ServerAlias subdomain1.youydomain.com
DocumentRoot /home/rootdir/subdomain
ErrorLog logs/error_log
CustomLog logs/visit_log
</VirtualHost>

NOTE :
You can create n number of SubDoamins on one IP address

Apache's Module (Somthing useful in httpd.conf for Web Programmer)

If you want to include any New settings whithout editing
httpd.conf file then copy following line once into your server
httpd.conf file. And later if you want to add new Module then edit subdomain.conf
and restart the server.
#------------------------------------------
Include /home/jyve_conf/subdomain.conf
#------------------------------------------


DirectoryIndex: sets the file that Apache will serve if a directory
is requested. If you requested http://yourdomain.com then server will automatically search index.html first for default file if not found then search for any mathch in the follwing list. You can list any file which you want to serve as default when user request for directory
#-------------------------------------------------------
DirectoryIndex index.html index.html.var index.php3
#-------------------------------------------------------


if your .htaccess is file is not working then add following lines in httpd.conf
(red) is folder path where .htaccess file located.
#-------------------------------------------------------------
<Directory /home/vikrant/userprofile>
AllowOverride All
</Directory>
#-------------------------------------------------------------



Important Linux Commands

Tar , UnTar and UnZip
--------------------------------
tar -zxf 18012005.tar vikrant/
tar -zcf newtitle.tar *.php
unzip myzip.zip

Folder SIZE
----------------
du -skh * | less -- Check the folder size
du -skh *| grep M | less -- Check the folder size which has MB

SCP:
-------------
-->Upload File to Server
# scp config.php username@www.youdomain.com:/home/rootdir/filename.php

-->Download file from server on Currnet directory.
# scp username@www.youdomain.com:/home/rootdir/filename.php .

Fetch (Download files from server)
-----------------------------------------
#wget http://yuordomain.com .

List Contents of Directory
---------------------------------
ls -l | wc -- (Get Number of Files /Content)
ls -lah -- (Human redable file size)

Check ServerLoad
----------------------
w

CronTab Quick Reference

What is Cron Tab ?
cron is a unix utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon often termed as cron jobs.
Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.

Restriction
You can execute crontab if your name appears in the file
/usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file
/usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.

Commands
export EDITOR=vi ;to specify a editor to open crontab file.

crontab -e Edit your crontab file, or create one if it doesn't already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)

Crontab File
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.
* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (1 - 7) (monday = 1)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

Environment
cron invokes the command from the user's HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so
in the crontab entry or in a script called by the entry.

Disable Email
By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .

>/dev/null 2>&1

Generate Log File
To collect the cron execution execution log in a file :

30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

Examples :
Cron set For Database BackUp

5 21 * * * mysqldump -u root -pclarion --opt specto | gzip > /backup1/amodd/spec
to_`date +%Y%m%d%H%M`.gz

Cron Set for run PHP File ..
* 0,6,12,18 * * * /usr/bin/php -q /var/www/html/vikrant/goskype/expertblog/blogsadmin/runcron.php > /dev/null


HTTP Authentication to Folder. (.htaccess /.htpasswd)

Write Following code in .htaccess file and save it into the folder which you want to
authonticate.

Change the path (In red) and enter the Folder path which you want to authenticate.

------------------------------------------------------------------

AuthUserFile /mnt/web/guide/somewhere/somepath/.htpasswd
AuthGroupFile /dev/null
AuthName "Somewhere.com's Secret Section"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>

--------------------------------------------------------------------
To create an .htpasswd file, login to the server via telnet(Command line) go to the directory you specified in AuthUserFile. In the example, this is /mnt/web/guide/somewhere/somepath. Then use the htpasswd program with the -c switch to create your .htpasswd in the current directory. (as per following)

----------------------------------------
htpasswd -c .htpasswd username
Adding password for username.
New password:
password
Re-type new password:
password
---------------------------------------

To delete users, open the .htpasswd file in a text editor and delete the appropriate lines:



Execute PHP syntax in .HTML file

If you want to run PHP code in .html extention file
Then Follow following procedures.

1. Write Following code in the .htaccess file
---------------------------------------------
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
-----------------------------------------------------

2. Upload it to your server (to your WWW root) where your
.html files are located in which contains PHP code.

Thats the idea.

Wednesday, December 08, 2004

What Is osCommerce?

One of the Best Scripts I have ever Seen ?

Strong eCommerce Tool .


See More Documents on :

1. http://wiki.oscommerce.com

2. http://forums.oscommerce.com

osCommerce is an online shop e-commerce solution under on going development by the open source community. Its feature packed out-of-the-box installation allows store owners to setup, run, and maintain their online stores with minimum effort and with absolutely no costs or license fees involved.

osCommerce combines open source solutions to provide a free and open e-commerce platform, which includes the powerful PHP web scripting language, the stable Apache web server, and the fast MySQL database server.

With no restrictions or special requirements, osCommerce is able to run on any PHP enabled web server, on any environment that PHP and MySQL supports, which includes Linux, Solaris, BSD, Mac OS X, and Microsoft Windows environments.

osCommerce was started in March 2000 and has since matured to a solution that is currently powering thousands of live shops around the world.

Today, osCommerce has been taken to the next level, moving towards an e-commerce framework solution that not only remains easy to setup and maintain, but also making it easier for store administrators to present their stores to their customers with their own unique requirements.

The success of osCommerce is secured by a dedicated team and a great and active community where members help one another out and participate in development issues reflecting upon the current state of the project.

Monday, November 22, 2004

LDAP

LDAP, Lightweight Directory Access Protocol, is an Internet protocol that email programs use to look up contact information from a server, such as ClickMail Central Directory.

As soon as Internet email became popular, it was clear we needed a good phone book. Printed directories were obsolete before the ink was dry. Older Internet methods of looking up names, such as whois, Ph, or finger, were limited or arcane. Every email program has a personal address book, but how do you look up an address for someone who's never sent you email? How can an organization keep one centralized up-to-date phone book that everybody has access to?

That's why software companies such as Microsoft, IBM, Lotus, and Netscape agreed to support a standard called LDAP. "LDAP-aware" client programs can ask LDAP servers to look up entries in a wide variety of ways. LDAP servers index all the data in their entries, and "filters" may be used to select just the person or group you want, and return just the information you want. For example, here's an LDAP search translated into plain English: "Search for all people located in Chicago whose name contains "Fred" that have an email address. Please return their full name, email, title, and description." (However, many email clients have more limited search and retrieval options.)

"Permissions" are set by the administrator to allow only certain people to access the LDAP database, and optionally keep certain data private. LDAP servers also provide "authentication" service, so that web, email, and file-sharing servers (for example) can use a single list of authorized users and passwords.

LDAP was designed at the University of Michigan to adapt a complex enterprise directory system (called X.500) to the modern Internet. A directory server runs on a host computer on the Internet, and various client programs that understand the protocol can log into the server and look up entries. X.500 is too complex to support on desktops and over the Internet, so LDAP was created to provide this service "for the rest of us."

LDAP servers exist at three levels: There are big public servers such as BigFoot and Infospace, large organizational servers at universities and corporations, and smaller LDAP servers for workgroups.

You probably already have an LDAP-aware client installed on your computer. Most modern email clients are set up to search an LDAP directory for email addresses. These include Outlook, OS X Mail, Eudora, Netscape, QuickMail Pro, and Mulberry.

LDAP has broader applications, such as looking up services and devices on the Internet (and intranets). Netscape Communicator can store user preferences and bookmarks on an LDAP server. There is even a plan for linking all LDAP servers into a worldwide hierarchy, all searchable from your client.

LDAP promises to save users and administrators time and frustration, making it easy for everyone to connect with people without frustrating searches for email addresses and other trivia.



Wednesday, October 13, 2004

PHP5 and OOPs

New Object Model

In PHP 5 there is a new Object Model. PHP's handling of objects has been completely rewritten, allowing for better performance and more features. In previous versions of PHP, objects were handled like primitive types (for instance integers and strings). The drawback of this method was that semantically the whole object was copied when a variable was assigned, or pass as a parameter to a method. In the new approach, objects are referenced by handle, and not by value (one can think of a handle as an object's identifier).

Many PHP programmers aren't even aware of the copying quirks of the old object model and, therefore, the majority of PHP applications will work out of the box, or with very few modifications.

The new Object Model is documented at the Language Reference.

Saturday, October 02, 2004

Skype - Jyve

What is Jyve.com?

Author : Vikrant Labde
Programmer of Jyve.com
Jyve.com is one of the biggest site which helps skype to improve the skype community.

Advantages of Jyve.com
Jyve has provides very strong features which are totally integrated with the Skype
such as Jyve Groups
Jyve Mails
Jyve Forums
Jyve YellowPages
Jyve ContactSystem
Jyve Blog

and many other features .

Directory Search.
Jyve has managed aprox.3000 Interests crateria. Now you can find people for your interest on Jyve and contact that user Via Skype or IM that user via Skype .

Now Dont West Time ! and Join Skype Community.

Posted By: Vikrant Labde
Softwate Engineer
(Clarion Technologies)

Email Me : vikrantlabde@yahoo.com
vikrantlabde @hotmail.com


What is Skype?

Hello. We’re Skype and we’ve got something we want to share with you.

We’ve got a simple bit of software we want to give you. It’ll let you make free phone calls to your friends all over the world. And we don’t want any money for it. It’s free.

You could think of us as the big, free Internet telephony company. We prefer to think of ourselves as a big group hug, even a present. Yes… that’s it… we’re a present… but without the ribbon.

Our software’s quick and easy to install. Just download Skype, register and within minutes you can plug in your headset, speakers or USB phone and call your friends. The calls have excellent sound quality and are highly secure with end-to-end encryption. You don’t even need to reconfigure your firewall or router. It just, you know… works.

You can also use our SkypeOut function to make calls to friends who only have a landline or mobile phone anywhere in the world at local rates. You can even transfer files of up to 2 gigabytes.

Now what do we ask of you in return? A bag of seed? A back rub? The keys to your city? No. We just want you to share us with all your friends. Why? Well, you can only speak to your friends for free on Skype, if they’re also using Skype. So the more people you share it with, the more people you can talk to. Simple when you think about it… so, is it a deal?

» Learn more about Skype
» P2P telephony explained – for geeks only
» More information on SkypeOut and SkypeOut prices

When will version 1.0 for Linux arrive?

The version 1.0 release that was launched on July 27 was for the Windows platform, as well as the SkypeOut service. The Linux version 1.0 is on its way and new versions are coming out for closed testing all the time and will reach the public once they're ready. There will not be a significant leap in features between before-1.0 and post-1.0 versions - it's a gradual evolution as we continuously innovate and improve the software.

How does Skype compete with for example MSN which has the largest share of the instant messaging market?

Skype offers free superior sound quality Internet telephony. In addition, it includes:

  • Conference calling - enables simultaneous and seamless voice communication between groups of up to five friends, family or colleagues. The Linux version currently has only conference client but will have hosting too.
  • Global Directory - the user-built global Skype contacts directory with numerous search options and an easy add-a-contact tool
  • Customization - My Picture image display
  • Mobility - login into Skype account on more than one PC anywhere in the world.
  • Multiple Skype accounts on one PC

In comparison with other IM/voice clients, we can ensure:

  • Better usability in networks. MSN and many other VoIP providers have voice calls, but those cannot penetrate firewalls or NAT. Skype has solved this problem. The same goes for other forms of communication (file transfers, instant messages) that sometimes don't go through firewalls.
  • Better performance. MSN is server-based, meaning that performance suffers in peak hours and users simply cannot do voice calls due to server overload. Skype calls are truly P2P, involving the distributed network itself for routing calls, so it scales up very well and does not suffer from this kind of performance problems.

We are working on adding more user requested features to the software, such as video calling, etc.

Why Skype writing software for Linux?

Skype for Linux was one of the most requested developments from our user base, but also because we see Linux as an important emerging PC desktop platform. This is illustrated by the fact that many major vendors are starting to offer Linux systems (HP, Sun, IBM to name just a few), and that many companies, government institutions and local governments in Europe, Asia and elsewhere have announced their migration to Linux. The proportion of Skype for Linux users is still small as compared to those running it on Windows, but we expect it to increase over the coming years.

Simply put, we want everyone to be able to run Skype and talk to their friends, family and colleagues, regardless of what platform they use or whether they have a computer at all. Embedded and mobile devices, some of them on Embedded Linux, are an important future development path for Skype.

How many people are working fulltime on Skype?

We have approximately 45 people working on Skype.

Skype launches Pocket PC software

Peer-to-peer IP telephony startup Skype yesterday released a version of its software designed for mobile devices running Microsoft's PocketPC operating system. Skype for Pocket PC version 1.0 allows users of wireless LAN-enabled PDAs running Microsoft's Windows Mobile 2003 for Pocket PC to make Voice over IP calls from Wi-Fi hotspots. As with PC versions of the software, the technology allows users to make free voice calls to other Skype users over a broadband P2P network. Skype for Pocket PC enables cross-platform voice calls to other Skype users running either Windows, Linux or the recently released Mac OS X versions of Skype. All Skype software is free. The Pocket PC version of Skype

Installing the software on a HP iPAQ Pocket PC 5500 proved straightforward. We were able to easily set up a pair of calls and the voice quality was surprisingly good, providing you both remember not to attempt talking at the same time. Oddly, it was easier to have a clear conversation with someone in the Northampton area than someone in the office next door.

The release is something of a boon for geeks who will be able to use the software to turn WiFi-enabled iPAQ and the like into something resembling Star Trek-style communicators. Skype users control their online presence and contact lists, and have options to customise their overall experience.

Skype for Pocket PC Free offers end-to-end encryption for privacy along with conference calling and instant messaging features. The application includes a service, called SkypeOut, that allows Skype users to pre-pay and use their computing device and Internet connection to call landlines and mobile phones anywhere in the world at local rates (pricelist here). SkypeOut pricing starts at approximately two cents per minute (for the US, Western Europe and Australia). Rates in the developing world are far more expensive.

"With the launch of Skype for Pocket PC 1.0, Skype is expanding consumer choice in mobile, global communications by offering free Skype-to-Skype calling and affordable SkypeOut calls to any traditional phone number," said Niklas Zennström, Skype chief executive and co-founder. "We are delivering greater platform and portability options for consumers looking to take advantage of the cost and quality benefits of internet telephony. We will continue to expand platform choices for our users."